/*编写一个程序，生成1000个1-10之间的随机数，检测每个数字出现的次数，若使用不同的种子值
生成的数字的次数相同与否？*/
#include <stdio.h>
#include <stdlib.h>

#define SIZE 1000

void count_print(int* zu,int n);

int main(void)
{
	int seed;
	int i;
	int arr[SIZE];
	printf("enter your seed\n");
	scanf_s("%d", &seed, 4);
	srand(seed);//此函数是用来重置种子的。
	for (i = 0; i <= SIZE - 1; i++)
		arr[i] = rand() % 10 + 1;
	count_print(arr,SIZE);
	return 0;
}

void count_print(int* zu,int n)
{
	int i;
	int count[10];
	for (i = 0; i <= 9; i++)
		count[i] = 0;
	for (i = 0; i <= n - 1; i++)
	{
		switch (zu[i])//这样做很蠢，但程序执行的效率高。
		{
		case 1:
			count[0]++;
			break;
		case 2:
			count[1]++;
			break;
		case 3:
			count[2]++;
			break;
		case 4:
			count[3]++;
			break;
		case 5:
			count[4]++;
			break;
		case 6:
			count[5]++;
			break;
		case 7:
			count[6]++;
			break;
		case 8:
			count[7]++;
			break;
		case 9:
			count[8]++;
			break;
		case 10:
			count[9]++;
			break;
		}
	}
	for (i = 0; i <= 9; i++)
		printf("%d has %d\n", i + 1, count[i]);
}